package com.emdata.competition.common;

import lombok.Data;

import java.io.Serializable;

/**
 * @author zhoukai
 * @date 2020/3/21 13:35
 */
@Data
public class ResultData<T> implements Serializable {
    private static final long serialVersionUID = -3124326062679793506L;

    private Boolean success;
    private T data;
    private String msg;

    public ResultData() {
    }

    public ResultData(Boolean success) {
        super();
        this.success = success;
    }

    public ResultData(Boolean success, T data) {
        super();
        this.success = success;
        this.data = data;
    }

    public ResultData(String msg) {
        super();
        this.msg = msg;
    }

    public ResultData(Boolean success, T data, String msg) {
        this.success = success;
        this.data = data;
        this.msg = msg;
    }

    public static <T> ResultData<T> success(T data) {
        return new ResultData<>(true, data);
    }

    public static <T> ResultData<T> success() {
        return new ResultData<>(true);
    }

    public static <T> ResultData<T> error() {
        return new ResultData<>(false);
    }

    public static <T> ResultData<T> error(String msg) {
        return new ResultData<>(false, null, msg);
    }

}
